/* eslint valid-jsdoc: "off" */

'use strict';
const path = require('path');

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1579076727443_8667';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  config.mysql = {
    // database configuration
    client: {
      // host
      host: '39.105.208.238',
      // port
      port: '3306',
      // username
      user: 'root',
      // password
      password: 'cm@1212',
      // database
      database: 'react_blog',    
    },
    // load into app, default is open
    app: true,
    // load into agent, default is close
    agent: false,
  };
  

  config.security={
    csrf:{
      enable:false
    },
    domainWhiteList:['*']        //允许所有的接口跨域
    // domainWhiteList:['http://blog.cm1212.com','http://admin.cm1212.com']    //跨域白名单
    // domainWhiteList:['http://localhost:3000','http://localhost:3001']     //本地跨域白名单
  }
  config.cors={
    // origin:'*',  //允许所有跨域访问，注释掉则允许上面 白名单 访问
    credentials: true,    //允许Cookie session 跨域
    allowMethods:'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
  }
  exports.logger = {
	  dir: path.join(appInfo.baseDir, 'logs')
	};

  return {
    ...config,
    ...userConfig,
  };
};


